package common

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/common"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// PreAuthRevokeService 预授权撤销服务
type PreAuthRevokeService struct {
	*services.BaseService
}

// NewPreAuthRevokeService 创建预授权撤销服务
func NewPreAuthRevokeService(config *core.Config) *PreAuthRevokeService {
	return &PreAuthRevokeService{
		BaseService: services.NewBaseService(config),
	}
}

// PreAuthRevoke 预授权撤销
func (s *PreAuthRevokeService) PreAuthRevoke(request *common.PreAuthRevokeRequest) (*common.PreAuthRevokeResponse, error) {
	response := common.NewPreAuthRevokeResponse()
	err := s.Post(request, response, "/open/trans/preauthrevoke")
	if err != nil {
		return nil, err
	}
	return response, nil
}
